﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLK.Database.DALs;

namespace QLK.Database.BLLs
{
    public  class InvoicesProductBLL
    {
        private InvoiceProductDAL DAL;
        public InvoicesProductBLL()
        {
            DAL = new InvoiceProductDAL();
        }
        public Invoices_Product GetInvoiceProductByProductID(int productID)
        {
            if (productID > 0)
                return DAL.GetInvoiceProductByProductID(productID);
            return null;
        }
        public IEnumerable<Invoices_Product> GetAllInvoiceProduct()
        {
            return DAL.GetAllInvoiceProduct();
        }
        public bool DeleteInvoiceProductByProductID(int productID)
        {
            return DAL.DeleteInvoiceProductByProductID(productID);
        }
        public bool UpdateInvoiceProduct(Invoices_Product invoice)
        {
            if (!DAL.CheckDuplicateInvoiceProductByInvoiceID(invoice.ProductID))
            {
                return DAL.UpdateInvoiceProduct(invoice);
            }
            return false;
        }
        public bool InsertInvoiceProduct(Invoices_Product invoice)
        {
            if (!DAL.CheckDuplicateInvoiceProductByInvoiceID(invoice.ProductID))
            {
                return DAL.InsertInvoiceProduct(invoice);
            }
            return false;
        }
        public void DeleteInvoiceProductByProductID(Invoices_Product invoice)
        {
            throw new NotImplementedException();
        }
    }
}
